package com.boco.webmaster.common.consts;

import java.util.*;
import javax.servlet.http.HttpServletRequest;

public class AppletScreenSize {
    private static Map appletScreenMap = new HashMap();

    static {
        appletScreenMap.put("1024", new String[] {"850", "510"});
        appletScreenMap.put("1280", new String[] {"1110", "760"});
        appletScreenMap.put("1600", new String[] {"1420", "920"});
        appletScreenMap.put("default", new String[] {"906", "510"});
    }

    private AppletScreenSize() {
    }


    public static String[] getAppletScreenSize(HttpServletRequest request) {
        int display = com.boco.webmaster.common.web.JspHelper.getScreenWidth(request);
        String[] screenSize = null;
        if (display == 1024 || display == 1280 || display == 1600) {
            screenSize = (String[]) appletScreenMap.get(Integer.toString(display));
        } else {
            screenSize = (String[]) appletScreenMap.get("default");
        }
        return screenSize;
    }

    public static int getAppletHeight(HttpServletRequest request) {
        String[] screenSize = getAppletScreenSize(request);
        return Integer.parseInt(screenSize[1]);
    }

    public static int getAppletWidth(HttpServletRequest request) {
        String[] screenSize = getAppletScreenSize(request);
        return Integer.parseInt(screenSize[0]);
    }
}
